package com.ruoyi.process.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.process.service.DeviceRepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description:
 * @ProjectName: ruoyi
 * @Package: com.walker.process.controller
 * @ClassName: MyTaskController
 * @Author: yangyl
 * @CreateDate: 2022/4/23 23:14
 */
@RestController
@RequestMapping("/myTask")
public class MyTaskController {

    @Autowired
    private DeviceRepairService deviceRepairService;

    @PostMapping("/apply")
    @Log(title = "申请接口", businessType = BusinessType.INSERT)
    public AjaxResult apply(@RequestBody Map<String,Object> params){
        return deviceRepairService.apply(params);
    }

    @GetMapping("/todoList")
    public AjaxResult todoList(@RequestParam Integer pageNum,@RequestParam Integer pageSize){
        return deviceRepairService.todoList(pageNum,pageSize);
    }
    @GetMapping("/todoCount")
    public AjaxResult todoCount(){
        return deviceRepairService.todoCount();
    }

    @PostMapping("/completeTask")
    @Log(title = "完成任务", businessType = BusinessType.OTHER)
    public AjaxResult completeTask(@RequestBody Map<String,Object> params){
        return deviceRepairService.completeTask(params);
    }

    @GetMapping("/flowRecord")
    public AjaxResult flowRecord(String procInsId){
        return deviceRepairService.flowRecord(procInsId);
    }

    /**
     * 我的任务列表
     * @return
     */
    @GetMapping("/finishTaskList")
    public AjaxResult finishTaskList(@RequestParam Integer pageNum,@RequestParam Integer pageSize,
                                     @RequestParam(required = false) String startTime,@RequestParam(required = false) String endTime){
        Map<String,Object> otherMap=new HashMap<>();
        otherMap.put("startTime",startTime);
        otherMap.put("endTime",endTime);
        return deviceRepairService.finishTaskList(pageNum,pageSize,otherMap);
    }

}
